#include "widget.h"
#include "ui_widget.h"
#include "server.h"
#include <QPushButton>
#include <QIcon>
#include <QHBoxLayout>
#include <QResource>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    // QHBoxLayout *layout = new QHBoxLayout(this);
    // QPushButton *button = new QPushButton();
    // button->setFixedSize(50, 50);
    // //button->setIcon(QIcon(":/test/test.png"));
    // //button->setIcon(QIcon(":/logo/logo.png"));
    // //button->setIcon(QIcon(":/res/logo.png"));
    // button->setIcon(QIcon(":/resource/image/logo.png"));
    // button->setIconSize(QSize(50, 50));
    // layout->addWidget(button);

    // qDebug() << QResource::registerResource("resource.rcc"); // 查看是否注册成功
    // QPixmap pix(":/resource/image/logo.png");
    // qDebug() << pix.isNull(); // 若 true，说明资源还是没进去
}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_pushButton_clicked()
{
    //发送文本消息请求
    WebSocketServer* websocketServer = WebSocketServer::getInstance();
    emit websocketServer->sendTextResp();
}


void Widget::on_pushButton_2_clicked()
{
    //发送删除好友请求
    WebSocketServer* websocketServer = WebSocketServer::getInstance();
    emit websocketServer->sendFriendRemove();
}

void Widget::on_pushButton_3_clicked()
{
    //发送好友申请
    WebSocketServer* websocketServer = WebSocketServer::getInstance();
    emit websocketServer->sendAddFriendApply();
}


void Widget::on_pushButton_4_clicked()
{
    //推送同意好友申请结果
    WebSocketServer* websocketServer = WebSocketServer::getInstance();
    emit websocketServer->sendFriendApplyProcess(true);
}


void Widget::on_pushButton_5_clicked()
{
    //推送拒绝好友申请结果
    WebSocketServer* websocketServer = WebSocketServer::getInstance();
    emit websocketServer->sendFriendApplyProcess(false);
}


void Widget::on_pushButton_6_clicked()
{
    //发送创建群聊请求
    WebSocketServer* websocketServer = WebSocketServer::getInstance();
    emit websocketServer->sendCreateGroupChatSession();
}


void Widget::on_pushButton_7_clicked()
{
    //发送图片消息请求
    WebSocketServer* websocketServer = WebSocketServer::getInstance();
    emit websocketServer->sendImageResp();
}


void Widget::on_pushButton_8_clicked()
{
    //发送文件消息请求
    WebSocketServer* websocketServer = WebSocketServer::getInstance();
    emit websocketServer->sendFileResp();
}



void Widget::on_pushButton_9_clicked()
{
    //发送语音消息请求
    WebSocketServer* websocketServer = WebSocketServer::getInstance();
    emit websocketServer->sendSpeechResp();
}

